From 75a80fd8804493b010d88bb550084ad5493fc15a Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Tue, 7 Mar 2023 07:32:59 -0700 Subject: [PATCH] support subsecond resolution for trackfilter start/stop options. (#1026) * support subsecond resolution for trackfilter start/stop options. * de-ickify track filter start/stop implementation. --- trackfilter.cc | 16 +++++++++------- xmldoc/filters/options/track-start.xml | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/trackfilter.cc b/trackfilter.cc index 349ea190a..b1cd3119e 100644 --- a/trackfilter.cc +++ b/trackfilter.cc @@ -676,17 +676,19 @@ QDateTime TrackFilter::trackfilter_range_check(const char* timestr) { QDateTime result; - static const QRegularExpression re("^(\\d{0,14})$"); + QString start(timestr); + QString fmtstart("00000101000000.000"); + fmtstart.replace(0, start.size(), start); + + static const QRegularExpression re(R"(^\d{14}\.\d{3}$)"); assert(re.isValid()); - QRegularExpressionMatch match = re.match(timestr); + QRegularExpressionMatch match = re.match(fmtstart); if (match.hasMatch()) { - QString start = match.captured(1); - QString fmtstart("00000101000000"); - fmtstart.replace(0, start.size(), start); - result = QDateTime::fromString(fmtstart, "yyyyMMddHHmmss"); + // QTime::fromString zzz expects exactly 3 digits representing milliseconds. + result = QDateTime::fromString(match.captured(0), "yyyyMMddHHmmss.zzz"); result.setTimeSpec(Qt::UTC); if (!result.isValid()) { - fatal(MYNAME "-range-check: Invalid timestamp \"%s\"!\n", qPrintable(start)); + fatal(MYNAME "-range-check: Invalid timestamp \"%s\"!\n", timestr); } #ifdef TRACKF_DBG diff --git a/xmldoc/filters/options/track-start.xml b/xmldoc/filters/options/track-start.xml index bb61ae634..446de40d3 100644 --- a/xmldoc/filters/options/track-start.xml +++ b/xmldoc/filters/options/track-start.xml @@ -9,7 +9,7 @@ dawn of time or January 1, 1970, whichever was later. The time for this option is expressed in UTC. -The value of this option must be in the form of YYYYMMDDHHMMSS, but it is +The value of this option must be in the form of YYYYMMDDHHMMSS.SSS, but it is not necessary to specify the smaller time units if they are not needed. That is, if you only care about points logged between 10 AM and 6 PM on a given date, you need not specify the minutes or seconds. -- 2.30.2